/*
 * Created by JFormDesigner on Fri Dec 24 20:31:06 GMT+08:00 2021
 */

package hpasUserInterfaces.itemQueryPage;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import com.jgoodies.forms.factories.*;
import com.jgoodies.forms.layout.*;
import hpasDataEntities.Hardware;
import hpasDataEntities.HardwareItem;
import hpasDataEntities.Retailer;

/**
 * @author laeva
 */
public class ItemDetailWindow extends JDialog {
    public ItemDetailWindow(Hardware hardware, HardwareItem item, Retailer retailer) {
        initComponents();
        loadData(hardware,item,retailer);
        button1.addActionListener(new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                dispose();
            }
        });
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        label1 = new JLabel();
        label2 = new JLabel();
        label3 = new JLabel();
        label4 = new JLabel();
        label5 = new JLabel();
        label6 = new JLabel();
        label7 = new JLabel();
        label8 = new JLabel();
        label9 = new JLabel();
        label10 = new JLabel();
        label11 = new JLabel();
        label12 = new JLabel();
        label13 = new JLabel();
        label14 = new JLabel();
        button1 = new JButton();

        //======== this ========
        setTitle("                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ");
        Container contentPane = getContentPane();

        //---- label1 ----
        label1.setText("\u578b\u53f7");

        //---- label2 ----
        label2.setText("\u5546\u54c1\u540d");

        //---- label3 ----
        label3.setText("text");

        //---- label4 ----
        label4.setText("text");

        //---- label5 ----
        label5.setText("\u5546\u5bb6\u540d");

        //---- label6 ----
        label6.setText("text");

        //---- label7 ----
        label7.setText("\u6e20\u9053\u540d");

        //---- label8 ----
        label8.setText("text");

        //---- label9 ----
        label9.setText("\u5730\u5740");

        //---- label10 ----
        label10.setText("text");

        //---- label11 ----
        label11.setText("\u63cf\u8ff0");

        //---- label12 ----
        label12.setText("text");

        //---- label13 ----
        label13.setText("\u4ef7\u683c");

        //---- label14 ----
        label14.setText("text");
        label14.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 20));
        label14.setForeground(new Color(240, 0, 0));

        //---- button1 ----
        button1.setText("\u786e\u5b9a");

        GroupLayout contentPaneLayout = new GroupLayout(contentPane);
        contentPane.setLayout(contentPaneLayout);
        contentPaneLayout.setHorizontalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addGroup(contentPaneLayout.createParallelGroup()
                        .addGroup(contentPaneLayout.createSequentialGroup()
                            .addGap(20, 20, 20)
                            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                .addComponent(label7, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                .addComponent(label5, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                .addComponent(label1, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                .addComponent(label2, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE)
                                .addComponent(label9)
                                .addComponent(label11, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                .addComponent(label13, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
                            .addGap(33, 33, 33)
                            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                .addComponent(label3, GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                                .addComponent(label4, GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                                .addComponent(label6, GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                                .addComponent(label8, GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                                .addComponent(label10, GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                                .addComponent(label12, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                                .addComponent(label14, GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)))
                        .addGroup(contentPaneLayout.createSequentialGroup()
                            .addGap(177, 177, 177)
                            .addComponent(button1)))
                    .addContainerGap(123, Short.MAX_VALUE))
        );
        contentPaneLayout.setVerticalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addGap(26, 26, 26)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label1)
                        .addComponent(label3))
                    .addGap(18, 18, 18)
                    .addGroup(contentPaneLayout.createParallelGroup()
                        .addComponent(label2)
                        .addComponent(label4))
                    .addGap(18, 18, 18)
                    .addGroup(contentPaneLayout.createParallelGroup()
                        .addComponent(label5)
                        .addComponent(label6))
                    .addGap(18, 18, 18)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label7)
                        .addComponent(label8))
                    .addGap(18, 18, 18)
                    .addGroup(contentPaneLayout.createParallelGroup()
                        .addComponent(label9)
                        .addComponent(label10))
                    .addGap(60, 60, 60)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label12, GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE)
                        .addComponent(label11))
                    .addGap(18, 18, 18)
                    .addGroup(contentPaneLayout.createParallelGroup()
                        .addComponent(label13)
                        .addComponent(label14))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE)
                    .addComponent(button1)
                    .addGap(26, 26, 26))
        );
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }
    private void loadData(Hardware hardware, HardwareItem item, Retailer retailer)
    {
        label3.setText(hardware.getModelNo());
        label4.setText(hardware.getProductName());
        label6.setText(retailer.getName());
        label8.setText(retailer.getHowToRetail());
        label10.setText(retailer.getAddress());
        label12.setText(hardware.getDescription());
        label14.setText(item.getPrice().toString());
        this.setTitle(hardware.getProductName()+" - 详细信息");
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JLabel label1;
    private JLabel label2;
    private JLabel label3;
    private JLabel label4;
    private JLabel label5;
    private JLabel label6;
    private JLabel label7;
    private JLabel label8;
    private JLabel label9;
    private JLabel label10;
    private JLabel label11;
    private JLabel label12;
    private JLabel label13;
    private JLabel label14;
    private JButton button1;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
